步进电机控制正转和反转,调速
#include "AT89X51.h"int delay();void inti_lcd();void show_lcd(int);void cmd_wr();void ShowState();void clock(unsigned int Delay) ;void DoSpeed(); //计算速度//正转值#define RIGHT_RUN 1//反转值#define LEFT_RUN 0sbit RS=0xA0;sbit RW=0xA1;sbit E=0xA2;char SpeedChar[]="SPEED(n/min):";char StateChar[]="RUN STATE:";char STATE_CW[]="CW";char STATE_CCW[]="CCW";char SPEED[3]="050";unsigned int RunSpeed=50;//速度unsigned char RunState=RIGHT_RUN; //运行状态main(){/*定时器设置*/TMOD=0x66; //定时器0,1都为计数方式;方式2;EA=1;//开中断TH0=0xff;//定时器0初值FFH;TL0=0xff;ET0=1;TR0=1;TH1=0xff;//定时器1初值FFH;TL1=0xff;ET1=1;TR1=1;
评论